package com.jetgege.smartbox;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Created by JJT-ssd on 2017/5/5.
 */

public class MenuAdapter extends BaseAdapter {

   // String [] muneName ={"我的消息","添加盒子","盒子设置","使用指南","关于我们"};
    String [] muneName ={"添加盒子","盒子设置","使用指南","关于我们"};
    @Override
    public int getCount() {
        return muneName.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view =null;
        ViewHolder viewHolder =null;
        if (convertView==null){
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.menu_list_item,parent,false);
            viewHolder=new ViewHolder();
            viewHolder.iv_MenuIcon = (ImageView)view.findViewById(R.id.iv_MenuIcon);
            viewHolder.tv_MenuName = (TextView)view.findViewById(R.id.tv_MenuName);
            view.setTag(viewHolder);
        }else {
            view=convertView;
            viewHolder =(ViewHolder)view.getTag();
        }
        switch (position){
            case 0:
                viewHolder.iv_MenuIcon.setImageResource(R.drawable.add_device);
                break;
            case 1:
                viewHolder.iv_MenuIcon.setImageResource(R.drawable.set_device);
                break;
            case 2:
                viewHolder.iv_MenuIcon.setImageResource(R.drawable.help);
                break;
            case 3:
                viewHolder.iv_MenuIcon.setImageResource(R.drawable.about);
                break;
            default:
                viewHolder.iv_MenuIcon.setImageResource(R.drawable.about);
                break;

        }

        viewHolder.tv_MenuName.setText(muneName[position]);
        return view;
    }

    class ViewHolder{
        ImageView iv_MenuIcon;
        TextView tv_MenuName;
    }
}
